{layout name="layout" /}
<div class="page">
<nav class="bar bar-tab">
<a class="tab-item" href="javascript:;" onclick="window.location.href='/'"><span class="icon icon-home"></span><span class="tab-label">竞赛首页</span></a>
<a class="tab-item active" href="javascript:;"  onclick="window.location.href='{$www_url}{:url('webapp/plusexam/history')}'"><span class="icon icon-message"></span><span class="tab-label">我的成绩</span></a>
 </nav>
<div class="content"><div id="TplList"></div></div></div>
<script id="Tpl" type="text/html">
{{# for(var i = 0, len = d.list.length; i < len; i++){ }}
{{#  if(d.list[i].id == 2){ }}
<div class="card deep link" url="{$www_url}{:url('webapp/plusexam/start')}?id={{d.list[i].id}}">
    <div class="card-header"><span>{{d.list[i].name}}</span><span class="more">限时:{{d.list[i].lock_time}}分<span class="icon icon-right"></span></span></div>
{{# }else{ }} 
<div class="card link" url="{$www_url}{:url('webapp/plusexam/start')}?id={{d.list[i].id}}">
    <div class="card-header"><span>{{d.list[i].name}}</span><span class="more"><span class="icon icon-right"></span></span></div>
{{#  } }}
  {{#  if(d.list[i].id == 2){ }}
  <div class="card-content">
    <div class="card-content-inner">
    共<span class="red">{{d.list[i].question_number}}</span>题,
    每题<span class="red">{{d.list[i].one_point}}</span>分,
    你有<span class="red">{{d.list[i].is_repeat}}</span>次机会</div>
  </div>
  {{#  } }}
  <div class="card-footer">{{d.list[i].start_time}} 至 {{d.list[i].end_time}}</div>
</div>
{{# } }}
</script>
<script id="Error" type="text/html">
<div class="page_msg">
    <div class="icon_area"><i class="icon_msg warn">!</i></div>
    <div class="text_area"><h2 class="title">{{d.message}}</h2></div>
</div>
</script>
<style type="text/css">
  .red{color: #FF0000;padding: 0rem 0.2rem;}
  .deep{background: #c8e6c9;}
</style>
<script type="text/javascript">
LazyLoad.css('/webview/light/css/icon.css');
LazyLoad.css('/webview/css/app.css');
LazyLoad.js(['/webview/jquery.2.1.4.js','/webview/light/js/light7.js','/webview/lib/laytpl.js'],function (){
    $.init();
    $.getJSON("{:url('webapp/plusexam/lists_api')}",function(data) {
        var data;var gettpl;
        if(data.code == 0){
          data = {"list":data.data};gettpl = $("#Tpl").html();
          laytpl(gettpl).render(data,function(html){$("#TplList").html(html);});
        }else{
          data = data;gettpl = $("#Error").html();
          laytpl(gettpl).render(data,function(html){$("#TplList").html(html);}); 
        }
        $(".link").click(function(){
          var urls = $(this).attr('url');
          $.get("{:url('webapp/Account/isAppLogin')}",function(data){
              if(data.code == 1){
                  islogin(data.message)
              }else{
                  window.location.href = urls;
                  //window.location.replace(urls);
              };
          });
        });
    });
})
function islogin(message){
    $.alert(message, function () {window.location.href="{:url('webapp/Account/index')}";});
}
</script>